using System;
using System.Collections.Generic;
using System.Text;

using System.Data;
using Husb.Data;
using Husb.DataUtil;
using Husb.Util;
using CentralOffice.Admin.Data;
using CentralOffice.Admin.DataAccess;
using AttendDutyTable = CentralOffice.Admin.Data.AttendDataSet.Attend_DutyDataTable;
using AttendDutyRow = CentralOffice.Admin.Data.AttendDataSet.Attend_DutyRow;

namespace CentralOffice.Admin.DataAccess
{
    public class AttendDutyAdapter : DataAccessAdapter<Admin.Data.AttendDataSet, AttendDutyTable, AttendDutyRow>
    {
        public const string DeleteAttendStoredProc = "Admin.AttendDuty_DeleteAttend_DutyDynamic";
        public AttendDutyAdapter()
        {
            this.TableName = "Attend_Duty";
            DeleteStoredProc = "Admin.AttendDuty_DeleteAttendDuty";

            GetAllStoredProc = "Admin.AttendDuty_SelectAttendDutyAll";
            UpdateStoredProc = "Admin.AttendDuty_UpdateAttendDuty";
            FindStoredProc = "Admin.AttendDuty_SelectAttendDutyDynamic";
            GetByIdStoredProc = "Admin.AttendDuty_SelectAttendDuty";
        }

        protected override void PopulateInsertParameters(Microsoft.Practices.EnterpriseLibrary.Data.Database db, System.Data.Common.DbCommand cmd)
        {
            db.AddInParameter(cmd, "UserId", DbType.String, "UserId", System.Data.DataRowVersion.Current);
            db.AddInParameter(cmd, "RegisterType", DbType.Int32, "RegisterType", System.Data.DataRowVersion.Current);
            db.AddInParameter(cmd, "RegisterTime", DbType.DateTime, "RegisterTime", System.Data.DataRowVersion.Current);
            db.AddInParameter(cmd, "RegisterIp", DbType.String, "RegisterIp", System.Data.DataRowVersion.Current);
            db.AddInParameter(cmd, "RegisterFlag", DbType.Int32, "RegisterFlag", System.Data.DataRowVersion.Current);
            db.AddInParameter(cmd, "Remark", DbType.String, "Remark", System.Data.DataRowVersion.Current);
        }
        protected override void PopulateUpdateParameters(Microsoft.Practices.EnterpriseLibrary.Data.Database db, System.Data.Common.DbCommand cmd)
        {
            //base.PopulateUpdateParameters(db, cmd);
            db.AddInParameter(cmd, "Id", DbType.Int32, "DutyId", System.Data.DataRowVersion.Current);
            PopulateInsertParameters(db, cmd);
        }

        public int DeleteAttend(string strFir, string strEnd,string strDuty,string strEvection,string strLeave,string strOut)
        {
            List<DatabaseParameter> parameters = new List<DatabaseParameter>();
            parameters.Add(new DatabaseParameter("FirDate", DbType.String, strFir));
            parameters.Add(new DatabaseParameter("EndDate", DbType.String, strEnd));
            parameters.Add(new DatabaseParameter("DutyFlag", DbType.String, strDuty));
            parameters.Add(new DatabaseParameter("EvectionFlag", DbType.String, strEvection));
            parameters.Add(new DatabaseParameter("LeaveFlag", DbType.String, strLeave));
            parameters.Add(new DatabaseParameter("OutFlag", DbType.String, strOut));

            return this.ExecuteNonQuery(DeleteAttendStoredProc, parameters, true, false);
        }
    }
}
